<template>
  <div class="person-card" :class="{ activeCard: conversationInfo.conversationId === pcCurrent }">
    <div class="info">
      <el-icon :size="16" style="margin: auto 5px auto 10px;" class="icon">
        <ChatLineSquare />
      </el-icon>
      <div class="info-detail">
        <div class="name">
          {{ conversationInfo.conversationName }}
        </div>
      </div>
      <el-dropdown trigger="click">
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item @click="renameConversation">重命名</el-dropdown-item>
            <el-dropdown-item divided @click="deleteConversation">删除</el-dropdown-item>
          </el-dropdown-menu>
        </template>
        <el-icon :size="16" style="margin: auto 5px auto 10px;" class="icon">
          <MoreFilled />
        </el-icon>
      </el-dropdown>
    </div>
  </div>
</template>

<script setup lang="ts">
import { MoreFilled, ChatLineSquare } from "@element-plus/icons-vue";
import { defineEmits, defineProps } from "vue";

const emit = defineEmits(['deleteConversation', 'renameConversation']);
const props = defineProps({
  conversationInfo: Object,
  pcCurrent: String
});

const deleteConversation = () => {
  emit('deleteConversation', props.conversationInfo.conversationId);
};

const renameConversation = () => {
  emit('renameConversation', props.conversationInfo.conversationId);
};
</script>


<style lang="scss" scoped>
.person-card {
  width: 200px;
  height: 60px;
  border-radius: 10px;
  border: 1px solid #b08d57; /* 金色边框 */
  background-color: #f0e6d2; /* 金色背景的浅色变体 */
  position: relative;
  margin: 25px 0;
  cursor: pointer;
  box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); /* 添加轻微阴影 */

  .info {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 95%;
    transform: translate(-50%, -50%);
    color: #705c3b; /* 深金色文字 */
    display: flex;

    .info-detail {
      margin-top: 5px;
      margin-left: 5px;
      width: 120px;

      .name {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        margin-bottom: 5px;
      }
    }

    .icon {
      width: 20px;
    }
  }

  &:hover {
    background-color: #b08d57; /* 悬停时背景色变为金色 */
    transition: 0.3s;
    border: none;
    box-shadow: 0px 0px 15px 3px rgba(176, 141, 87, 0.6); /* 金色阴影效果 */

    .info {
      color: #fff; /* 悬停时文字变为白色 */
    }
  }
}

.activeCard {
  background-color: #b08d57; /* 活动卡片的金色背景 */
  transition: 0.3s;
  border: none;
  box-shadow: 0px 0px 15px 3px rgba(176, 141, 87, 0.6); /* 活动卡片的金色阴影 */

  .info {
    color: #fff; /* 活动卡片的文字颜色 */
  }
}
</style>
